<?php
	function is_date($value, $format = 'yyyy-mm-dd')
	{
		if(strlen($value) == 10 && strlen($format) == 10){
	
			// find separator. Remove all other characters from $format
			$separator_only = str_replace(array('m','d','y'),'', $format);
			$separator = $separator_only[0]; // separator is first character
	
			if($separator && strlen($separator_only) == 2){
				// make regex
				$regexp = str_replace('mm', '[0-1][0-9]', $value);
				$regexp = str_replace('dd', '[0-3][0-9]', $value);
				$regexp = str_replace('yyyy', '[0-9]{4}', $value);
				$regexp = str_replace($separator, "\\" . $separator, $value);
	
				if($regexp != $value && preg_match('/'.$regexp.'/', $value)){
	
					// check date
					$day   = substr($value,strpos($format, 'd'),2);
					$month = substr($value,strpos($format, 'm'),2);
					$year  = substr($value,strpos($format, 'y'),4);
	
					if(@checkdate($month, $day, $year))
					return true;
				}
			}
		}
		
		return false;
	}
	

?>